package hezhiqin.com.autoconfigtation;

import hezhiqin.com.format.FormatProcessor;
import hezhiqin.com.format.JsonFormat;
import hezhiqin.com.format.StringFormat;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

/**
 * @program: homeWork
 * @description:
 * @author: hezhiqin
 * @create: 2020-03-03 15:02
 */
@Configuration
public class FormatAutoConfiguration {

    @Bean
    @Primary
    @ConditionalOnMissingClass("com.alibaba.fastjson.JSON")
    public FormatProcessor stringFormat(){
        return new StringFormat();
    }

    @ConditionalOnClass(name = "com.alibaba.fastjson.JSON")
    @Bean
    public FormatProcessor jsnFormat(){
        return new JsonFormat();
    }
}
